

FROM node:18.1-alpine

WORKDIR /build

# 设置 Node-Sass 的镜像地址
RUN npm config set sass_binary_site https://repo.huaweicloud.com/node-sass 

# 设置 npm 和 yarn 的镜像
RUN npm config set registry https://registry.npmmirror.com/
#RUN npm install -g npm@8.5.0
# RUN npm install -g yarn

# 设置 cnpm 的镜像
# RUN cnpm install -g yarn
RUN yarn config set registry 'https://registry.npmmirror.com/'

# 复制 package.json 并安装依赖
#COPY package.json yarn.lock ./
COPY package.json ./
RUN yarn install --registry='https://registry.npmmirror.com/'

# 复制整个项目并构建
COPY ./ ./
RUN yarn build

FROM nginx
RUN mkdir /app
COPY --from=0 /build/dist /app
COPY --from=0 /build/nginx.conf /etc/nginx/nginx.conf
COPY --from=0 /build/cert/loee.com.cn_bundle.crt /etc/nginx/loee.com.cn_bundle.crt
COPY --from=0 /build/cert/loee.com.cn.key /etc/nginx/loee.com.cn.key
COPY --from=0 /build/cert/exam.loee.com.cn_bundle.crt /etc/nginx/exam.loee.com.cn_bundle.crt
COPY --from=0 /build/cert/exam.loee.com.cn.key /etc/nginx/exam.loee.com.cn.key
COPY --from=0 /build/cert/scratch.loee.com.cn_bundle.crt /etc/nginx/scratch.loee.com.cn_bundle.crt
COPY --from=0 /build/cert/scratch.loee.com.cn.key /etc/nginx/scratch.loee.com.cn.key
COPY --from=0 /build/cert/oj.loee.com.cn_bundle.crt /etc/nginx/oj.loee.com.cn_bundle.crt
COPY --from=0 /build/cert/oj.loee.com.cn.key /etc/nginx/oj.loee.com.cn.key
EXPOSE 80
